package 小新养宠物;

//小新看到朋友养宠物非常羡慕，自己也想养宠物，
// 小新开始准备养一只老虎，被妈妈揍了一顿，于是他只好养了一条狗狗，
// 计划再养猫猫，或者鹦鹉等等，请通过代码完成这个过程。
public class Main {

    public static void main(String[] args) {

        Student xiaoxin = new Student();
        xiaoxin.feedPet(new Dog("小汪"));
        xiaoxin.feedPet(new Cat("小白"));
    }

}
class Student{
    public void feedPet( IPet pet ){
        pet.beFriendly();
        pet.beAccompanied();
    }
}
//定义接口
interface IPet{
        void beFriendly();
        void beAccompanied();
        }
//定义抽象类
  abstract class Animal{
    private String name;
//定义抽象方法
    public abstract void move();


    public Animal(String name) {
        super();
        this.name = name;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
//继承animal 实现IPet
class Cat extends Animal implements IPet{
    @Override
    public void beFriendly() {
        System.out.println("i am "+this.getName()+" cat, i am friendly");
    }

    @Override
    public void beAccompanied() {
        System.out.println("i am "+this.getName()+" cat, i can accompany you quiently");
    }

    public Cat(String name){
         super(name);
        }
//实现beFriendly方法

//实现be beAccompanied方法


@Override
public void move() {
        // TODO Auto-generated method stub
        System.out.println("cat move quiently");
        }
        }

//继承animal 实现IPet
class Dog extends Animal implements IPet{
    @Override
    public void beFriendly() {
        System.out.println("i am "+this.getName()+" dog, i am friendly");
    }

    @Override
    public void beAccompanied() {
        System.out.println("i am "+this.getName()+" dog, i can talk a walk with you");
    }

    public Dog(String name){
        super(name);
        }
//实现beFriendly方法

//实现be beAccompanied法



@Override
public void move() {
        // TODO Auto-generated method stub
        System.out.println("dog move quickly");
        }
        }